// Author: Bjorn Schobben

#include "HelpBrowser.h"
#include <QFile>

HelpBrowser::HelpBrowser(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags)
{
	// Call Qt Designer's setup function
	ui.setupUi(this);

	// Connect buttons with their actions
	QObject::connect(ui.forwardButton, SIGNAL(clicked()), ui.textBrowser, SLOT(forward()));
	QObject::connect(ui.backButton, SIGNAL(clicked()), ui.textBrowser, SLOT(backward()));
	QObject::connect(ui.homeButton, SIGNAL(clicked()), ui.textBrowser, SLOT(home()));
	QObject::connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(close()));

	// Enable/disable forward and back buttons when needed
	QObject::connect(ui.textBrowser, SIGNAL(backwardAvailable(bool)), ui.backButton, SLOT(setEnabled(bool)));
	QObject::connect(ui.textBrowser, SIGNAL(forwardAvailable(bool)), ui.forwardButton, SLOT(setEnabled(bool)));

    ui.textBrowser->setReadOnly(true);

	// Add the root directory "doc"  to the search path
	QStringList l;
	l << "../doc";
	ui.textBrowser->setSearchPaths(l);
	
}

void HelpBrowser::ShowPage(const QString& page)
{
	ui.textBrowser->setSource(QUrl(page));
}

HelpBrowser::~HelpBrowser()
{

}

